package mysql

import (
	"gorm.io/gorm"
	"time"
	user "watermelon/common/proto"
)

type Trip struct {
	gorm.Model
	UserId      int64     `gorm:"type:int" json:"user_id"`
	Destination string    `gorm:"type:varchar(50)" json:"destination"`
	FinishedAt  time.Time `gorm:"type:datetime" json:"finished_at"`
}

func (t *Trip) CreateTrip(in *user.UserCarReq) error {
	trips := &Trip{
		UserId:      in.UserId,
		Destination: in.Destination,
	}
	err := DB.Create(&trips).Error
	if err != nil {
		return err
	}
	return nil
}
